import './SetAdminRouterField.scss'

import { FormTempMapping } from '../../Utils/FormTemp'
import { useEventEmitter } from 'ahooks';
import { FlowThemeFormMapping } from '../../Config/FlowConfig'

const SetAdminRouterField = ({ data, Off }) => {
    const { item, FieldEvent } = data

    const inEvent = useEventEmitter()
    inEvent.useSubscription(val => {
        const { type, data } = val
        if (type === 'onFormBack') {
            FieldEvent.emit({ type: 'onModify', data: { ...item, ...data } })
            Off()
        }
    })

    return (
        <div className='SetAdminRouterField'>
            <FormTempMapping formItem={FlowThemeFormMapping['FlowMenuAPIField']} FORMEVENT={inEvent} Initial={item} />
        </div>
    );
};

export default SetAdminRouterField;